]> dgit.raspbian.org Git - ostree.git/commit
repo-commit: preserve existing object inode when staging to objects/
authorelectricface <songwentai@uniontech.com>
Mon, 29 Jun 2026 08:03:23 +0000 (16:03 +0800)
committerelectricface <songwentai@uniontech.com>
Wed, 8 Jul 2026 02:01:58 +0000 (10:01 +0800)
commit835d38b078f805b3600782c346bdb7505da950f1
treef7431f1b1c9758c44764825f64551cf68e63d20c
parent170ac983d4f2a17ae09167f4748d17eda122d66a
repo-commit: preserve existing object inode when staging to objects/

When ostree commit --consume is used and an object with the same
checksum already exists in objects/, rename_pending_loose_objects() was
unconditionally renaming the staging copy over it.  On Linux, renameat(2)
atomically replaces the destination for two regular files, silently
changing the inode of the existing repo object.

Fix this by checking whether the object already exists in objects/
before renaming.  If it does, the content is identical by definition
(the object store is content-addressed by SHA256), so we can simply
unlink the staging copy and keep the existing object with its original
inode.

Exception: .commitmeta objects are keyed by commit checksum rather than
their own content, so they can be updated in place (e.g. when GPG
signatures are added or deleted via ostree gpg-sign).  These are always
renamed unconditionally.
src/libostree/ostree-repo-commit.c